<?php
/**
 * Created by PhpStorm.
 * User: dev
 * Date: 18/11/14
 * Time: 1:56 PM
 */

class Admin_Utility_Sql_Controller extends Admin_Controller
{

    public $restful = true;

    public function __construct()
    {
        parent::__construct();
        //--Your Code --//
        $this->theme->set_theme("admin");
        $this->theme->set_layout("default");
    }


    public function get_index()
    {
        $this->theme->title("UTILITY : SQL");
        $data['title'] = 'SQL COMMAND';
        return $this->theme->render('admin::utility.sql',$data);
    }

    public function post_index()
    {
        $sql = Input::get('sql');
        DB::query($sql);

        if (mysql_errno()) {
            return Redirect::back()->with_input()->with('message','<div class="alert alert-danger">Invalid Operation !</div>');
        }else{
            return Redirect::back()->with('message','<div class="alert alert-danger">Executed !</div>');
        }
    }


}